package mapred.task.example;

import java.io.IOException;
import java.util.Iterator;

import mapred.task.extention.TextReducer;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapred.OutputCollector;
import org.apache.hadoop.mapred.Reporter;

public class LongSum_TextReducer extends TextReducer {

	@Override
	public void reduce(Text key, Iterator<Text> values,
			OutputCollector<Text, Text> output, Reporter reporter)
			throws IOException {
		long sum = 0;
		while (values.hasNext()) {
			sum += Long.parseLong(values.next().toString().trim());
		}
		output.collect(key, new Text(String.valueOf(sum)));
	}

    @Override
    protected void setUp() {
    }

}
